package model.backup.handlers;

import database.Database;
import java.sql.SQLException;
import model.backup.BackupProductFamily;

/**
 * Denne klasse bruges til at hente al data i bs_product_family og returnere det
 * @author junjie
 */
public abstract class BackupProductFamilyHandler {
    
    /**
     * Henter alle rækker i bs_product_family og returener et BackupProductFamily[] model
     * @return BackupProductFamily[]
     * @throws ClassNotFoundException
     * @throws SQLException 
     */
    public static BackupProductFamily[] getBackupProductFamily() throws ClassNotFoundException, SQLException
    {
        BackupProductFamily[] productFamilyArray = null;
        
        Database db = new Database();
        
        String[][] result = db.getFromDB("bs_product_family", "", "", "", "id", "name");
        productFamilyArray = new BackupProductFamily[result.length];
        
        db.closeDB();
        
        for (int i = 0; i < result.length; i++)
        {
            productFamilyArray[i] = new BackupProductFamily(Integer.parseInt(result[i][0]), result[i][1]);
        }
        
        return productFamilyArray;
    }
}
